using System;
using System.Collections.Generic;
using System.Reflection;
using System.Runtime.InteropServices;

using ILRuntime.CLR.TypeSystem;
using ILRuntime.CLR.Method;
using ILRuntime.Runtime.Enviorment;
using ILRuntime.Runtime.Intepreter;
using ILRuntime.Runtime.Stack;
using ILRuntime.Reflection;
using ILRuntime.CLR.Utils;
using System.Linq;

namespace ILRuntime.Runtime.Generated
{
    unsafe class huqiang_Pool_ModelBuffer_Binding
    {
        public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app)
        {
            BindingFlags flag = BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.DeclaredOnly;
            MethodBase method;
            FieldInfo field;
            Type[] args;
            Type type = typeof(huqiang.Pool.ModelBuffer);
            args = new Type[]{};
            method = type.GetMethod("CreateObject", flag, null, args, null);
            app.RegisterCLRMethodRedirection(method, CreateObject_0);
            args = new Type[]{typeof(UnityEngine.GameObject)};
            method = type.GetMethod("ReCycle", flag, null, args, null);
            app.RegisterCLRMethodRedirection(method, ReCycle_1);

            field = type.GetField("Index", flag);
            app.RegisterCLRFieldGetter(field, get_Index_0);
            app.RegisterCLRFieldSetter(field, set_Index_0);
            app.RegisterCLRFieldBinding(field, CopyToStack_Index_0, AssignFromStack_Index_0);
            field = type.GetField("type", flag);
            app.RegisterCLRFieldGetter(field, get_type_1);
            app.RegisterCLRFieldSetter(field, set_type_1);
            app.RegisterCLRFieldBinding(field, CopyToStack_type_1, AssignFromStack_type_1);


            app.RegisterCLRCreateArrayInstance(type, s => new huqiang.Pool.ModelBuffer[s]);

            args = new Type[]{typeof(System.Int64), typeof(System.Int32), typeof(System.Type[]), typeof(huqiang.Data.Container<huqiang.Pool.InstanceContext>)};
            method = type.GetConstructor(flag, null, args, null);
            app.RegisterCLRMethodRedirection(method, Ctor_0);

        }


        static StackObject* CreateObject_0(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject* ptr_of_this_method;
            StackObject* __ret = ILIntepreter.Minus(__esp, 1);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            huqiang.Pool.ModelBuffer instance_of_this_method = (huqiang.Pool.ModelBuffer)typeof(huqiang.Pool.ModelBuffer).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)0);
            __intp.Free(ptr_of_this_method);

            var result_of_this_method = instance_of_this_method.CreateObject();

            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
        }

        static StackObject* ReCycle_1(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject* ptr_of_this_method;
            StackObject* __ret = ILIntepreter.Minus(__esp, 2);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            UnityEngine.GameObject @obj = (UnityEngine.GameObject)typeof(UnityEngine.GameObject).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)0);
            __intp.Free(ptr_of_this_method);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
            huqiang.Pool.ModelBuffer instance_of_this_method = (huqiang.Pool.ModelBuffer)typeof(huqiang.Pool.ModelBuffer).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)0);
            __intp.Free(ptr_of_this_method);

            var result_of_this_method = instance_of_this_method.ReCycle(@obj);

            __ret->ObjectType = ObjectTypes.Integer;
            __ret->Value = result_of_this_method ? 1 : 0;
            return __ret + 1;
        }


        static object get_Index_0(ref object o)
        {
            return ((huqiang.Pool.ModelBuffer)o).Index;
        }

        static StackObject* CopyToStack_Index_0(ref object o, ILIntepreter __intp, StackObject* __ret, IList<object> __mStack)
        {
            var result_of_this_method = ((huqiang.Pool.ModelBuffer)o).Index;
            __ret->ObjectType = ObjectTypes.Integer;
            __ret->Value = result_of_this_method;
            return __ret + 1;
        }

        static void set_Index_0(ref object o, object v)
        {
            ((huqiang.Pool.ModelBuffer)o).Index = (System.Int32)v;
        }

        static StackObject* AssignFromStack_Index_0(ref object o, ILIntepreter __intp, StackObject* ptr_of_this_method, IList<object> __mStack)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            System.Int32 @Index = ptr_of_this_method->Value;
            ((huqiang.Pool.ModelBuffer)o).Index = @Index;
            return ptr_of_this_method;
        }

        static object get_type_1(ref object o)
        {
            return ((huqiang.Pool.ModelBuffer)o).type;
        }

        static StackObject* CopyToStack_type_1(ref object o, ILIntepreter __intp, StackObject* __ret, IList<object> __mStack)
        {
            var result_of_this_method = ((huqiang.Pool.ModelBuffer)o).type;
            __ret->ObjectType = ObjectTypes.Long;
            *(long*)&__ret->Value = result_of_this_method;
            return __ret + 1;
        }

        static void set_type_1(ref object o, object v)
        {
            ((huqiang.Pool.ModelBuffer)o).type = (System.Int64)v;
        }

        static StackObject* AssignFromStack_type_1(ref object o, ILIntepreter __intp, StackObject* ptr_of_this_method, IList<object> __mStack)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            System.Int64 @type = *(long*)&ptr_of_this_method->Value;
            ((huqiang.Pool.ModelBuffer)o).type = @type;
            return ptr_of_this_method;
        }



        static StackObject* Ctor_0(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject* ptr_of_this_method;
            StackObject* __ret = ILIntepreter.Minus(__esp, 4);
            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            huqiang.Data.Container<huqiang.Pool.InstanceContext> @contain = (huqiang.Data.Container<huqiang.Pool.InstanceContext>)typeof(huqiang.Data.Container<huqiang.Pool.InstanceContext>).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)0);
            __intp.Free(ptr_of_this_method);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
            System.Type[] @typ = (System.Type[])typeof(System.Type[]).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)0);
            __intp.Free(ptr_of_this_method);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 3);
            System.Int32 @buffersize = ptr_of_this_method->Value;

            ptr_of_this_method = ILIntepreter.Minus(__esp, 4);
            System.Int64 @type = *(long*)&ptr_of_this_method->Value;


            var result_of_this_method = new huqiang.Pool.ModelBuffer(@type, @buffersize, @typ, @contain);

            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
        }


    }
}
